Page({
	data: {
		urlAddress: getApp().globalData.imageUrl,
		goodsList: [],
		orderInfo: {
			orderGoods: [1]
		},
		isShow: true,
		class1: 'nomal',
		class2: 'nomal',
		class3: 'nomal',
		image1: 'default',
		image2: 'default',
		image3: 'default',
		image4: 'default',
		noteType: ''

	},
	onLoad: function(options) {
		// 生命周期函数--监听页面加载
		wx.showLoading({
			title: '加载中',
			mask: true
		})
		var _self = this;
		// setTimeout(function() {
		_self.getOrderInfo(options.code);
		// }, 3000)


	},
	getOrderInfo: function(code) {

		var _self = this;
		wx.request({
			url: getApp().globalData.baseUrl + '/applet/order/getOrderByOrderCode.do',
			data: {
				orderCode: code
			},
			header: getApp().globalData.header,
			success: function(res) {
				wx.hideLoading()
				_self.fitType(res.data.obj.reserveOrderVo.deliveryStatus)
				_self.setData({
					orderInfo: res.data.obj,
					isShow: false
				})
				if (res.data.obj.reserveOrderVo.deliveryModel == 20) {
					_self.setData({
						noteType: '配送'
					})
				} else {
					_self.setData({
						noteType: '自提'
					})
				}
				console.log(res)

			}
		})

	},
	fitType: function(type) {
		//配送状态(10：待付款；20：已支付；30：待打印；31:待收货；40:已完成；41:自动关单；43退款完成)
		switch (type) {
			case 10:
				this.setData({
					class1: 'nomal',
					class2: 'nomal',
					class3: 'nomal',
					image1: 'selected',
					image2: 'default',
					image3: 'default',
					image4: 'default'
				})
				break;
			case 20:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'nomal',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'default'
				})
				break;
			case 30:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'nomal',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'default'
				})
				break;
			case 31:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'nomal',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'default'
				})
				break;
			case 40:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'select',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'selected'
				})
				break;
			case 42:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'select',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'selected'
				})
				break;
			case 43:
				this.setData({
					class1: 'select',
					class2: 'select',
					class3: 'select',
					image1: 'selected',
					image2: 'selected',
					image3: 'selected',
					image4: 'selected'
				})
				break;
			default:
				this.setData({
					class1: 'nomal',
					class2: 'nomal',
					class3: 'nomal',
					image1: 'default',
					image2: 'default',
					image3: 'default',
					image4: 'default'
				})

		}

	},
	callOwers: function(e) {
		// console.log(e.currentTarget.dataset.code)
		var shopCode = e.currentTarget.dataset.code;
		var _self = this;

		wx.request({
			url: getApp().globalData.baseUrl + "/applet/reserve/getShopkeeperMobile.do",
			data: {

				shopCode: shopCode
			},
			header: getApp().globalData.header,
			success: function(res) {
				console.log(res);
				if (res.data.code == 200) {
					wx.showModal({
						title: '拨打店主电话',
						content: res.data.obj,
						success(ress) {
							if (ress.confirm) {
								wx.makePhoneCall({
									phoneNumber: res.data.obj
								})
							} else if (ress.cancel) {
								console.log('用户点击取消')
							}
						}
					})

				} else {
					wx.showModal({
						title: '拨打客服电话',
						content: '4000660158',
						success(res) {
							if (res.confirm) {
								wx.makePhoneCall({
									phoneNumber: '4000660158'
								})
							} else if (res.cancel) {
								console.log('用户点击取消')
							}
						}
					})

				}
			}
		})
	}
})